package com.wsllx.springboot.config;

import com.wsllx.springboot.annotation.ConditionalOnClass;
import com.wsllx.springboot.interfac.AutoConfiguration;
import com.wsllx.springboot.server.JettyWebServer;
import com.wsllx.springboot.server.TomcatWebServer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: shiguang-springboot
 * @description: web容器自动配置
 * @author: liulx
 * @create: 2022-09-28 20:48
 */
@Configuration
public class WebServiceAutoConfiguration implements AutoConfiguration {
	//有了条件注解，我们就可以来使用它了，那如何实现呢？
	//这里就要用到自动配置类的概念，我们先看代码：
	@Bean
	@ConditionalOnClass("org.apache.catalina.startup.Tomcat")
	public TomcatWebServer tomcatWebServer(){
		return new TomcatWebServer();
	}
	
	@Bean
	@ConditionalOnClass("org.eclipse.jetty.server.Server")
	public JettyWebServer jettyWebServer(){
		return new JettyWebServer();
	}
}
